package pathfinding
{

	//from AdvancED ActionScript 3.0 Animation by Keith Peters
	public class Grid
	{
		private var _startNode:Node;

		private var _endNode:Node;

		private var _nodes:Array;

		private var _numCols:int;

		private var _numRows:int;

		public function Grid(numCols:int, numRows:int)
		{
			_numCols = numCols;
			_numRows = numRows;
			_nodes = new Array();
			for (var i:int = 0; i < _numRows; i++)
			{
				_nodes[i] = new Array();
				for (var j:int = 0; j < _numCols; j++)
				{
					_nodes[i][j] = new Node(j, i);
				}
			}
		}

		public function getNode(x:int, y:int):Node
		{
			return _nodes[y][x] as Node;
		}

		public function setEndNode(x:int, y:int):void
		{
				_endNode = _nodes[y][x] as Node;
		}

		public function setStartNode(x:int, y:int):void
		{
			_startNode = _nodes[y][x] as Node;
		}

		public function setWalkable(x:int, y:int, value:Boolean):void
		{
			_nodes[y][x].walkable = value;
		}

		public function get endNode():Node
		{
			return _endNode;
		}

		public function get numCols():int
		{
			return _numCols;
		}

		public function get numRows():int
		{
			return _numRows;
		}

		public function get startNode():Node
		{
			return _startNode;
		}
	}
}